<template>
  <div>
    <h1 align="center">管理员登录</h1>
    <table class="table table-bordered">
      <tr>
        <td align="center">用户名</td>
        <td>
          <input type="text" v-model="state.use">
        </td>
      </tr>
      <tr>
        <td align="center">密码</td>
        <td>
          <input type="password" v-model="state.pwd">
        </td>
      </tr>
      <tr>
        <td align="center" colspan="2">
          <input type="button" value="登录" @click="ok" />
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted } from 'vue';
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
let data: any = reactive({
  state: {
    use:'',
    pwd:''
  }
});
let { state } = toRefs(data);
const ok = () => {
  let obj = {
      use:state.value.use,
      pwd:state.value.pwd
  };
  axios({
    url: '/api/Admin/DengLu',
    method: 'get',
    params: obj
  })
    .then((res) => {
      console.log(res);
      if (res.data.data == null) {
        alert('用户名不存在,请联系管理员');
        return;
      } else {
        alert('登录成功');
        router.push('/mshow');
      }
    })
    .catch((err) => {
      console.log(err);
    });
};
</script>

<style scoped></style>
